package com.graduation.smartparkingplatform.ServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.graduation.smartparkingplatform.Dao.RecordMapper;
import com.graduation.smartparkingplatform.Pojo.Record;
import com.graduation.smartparkingplatform.Service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {

  @Autowired RecordMapper recordMapper;

  // 获取停车记录列表（分页）
  @Override
  public PageInfo<Record> getRecordList(Integer page, Integer count) {
    PageHelper.startPage(page, count);

    List<Record> getRecordList = recordMapper.getdistinguishList();

    PageInfo<Record> pageInfo = new PageInfo<>(getRecordList);

    return pageInfo;
  }

  // 模糊搜索停车记录（分页）
  @Override
  public PageInfo<Record> searchRecord(Integer page, Integer count, String carPlate) {
    PageHelper.startPage(page, count);

    List<Record> recordList = recordMapper.searchRecord(carPlate);

    PageInfo<Record> pageInfo = new PageInfo<>(recordList);

    return pageInfo;
  }

  // 删除停车记录
  @Override
  public Boolean deleteRecord(Integer RecordId) {
    return recordMapper.deleteRecord(RecordId);
  }

  // 获取所有停车记录
  @Override
  public List<Record> getRecordListAll() {
    return recordMapper.getRecordListAll();
  }
}
